home *** CD-ROM | disk | FTP | other *** search
/ Aminet 48 / Aminet 48 (2002)(GTI - Schatztruhe)[!][Apr 2002].iso / Aminet / util / moni / Scout-src.lha / source / objects / scout_extras.c < prev    next >
Encoding:
C/C++ Source or Header  |  2002-02-13  |  26.2 KB  |  809 lines

  1. /**
  2.  * Scout - The Amiga System Monitor
  3.  *
  4.  *------------------------------------------------------------------
  5.  *
  6.  * This program is free software; you can redistribute it and/or modify
  7.  * it under the terms of the GNU General Public License as published by
  8.  * the Free Software Foundation; either version 2 of the License, or
  9.  * any later version.
  10.  *
  11.  * This program is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program; if not, write to the Free Software
  18.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19.  *
  20.  * You must not use this source code to gain profit of any kind!
  21.  *
  22.  *------------------------------------------------------------------
  23.  *
  24.  * @author Andreas Gelhausen
  25.  * @author Richard Körber <rkoerber@gmx.de>
  26.  */
  27.  
  28.  
  29.  
  30. #include "system_headers.h"
  31.  
  32. extern struct GfxBase   *GfxBase;
  33. extern struct ExecBase  *SysBase;
  34. extern APTR AboutText;
  35.  
  36. UBYTE  updatetimetext[] = "1.0\0\0\0\0\0";
  37. ULONG  updatetimestate;
  38.  
  39. ULONG MakeListID (char a, char b, char c, char d) {
  40.  
  41.    if (opts.SingleWindows) {
  42.       return ((ULONG) ('L')<<24 | (ULONG) ('I')<<16 | (ULONG) ('S')<<8 | (ULONG) ('T'));
  43.    } else {
  44.       return ((ULONG) (a)<<24 | (ULONG) (b)<<16 | (ULONG) (c)<<8 | (ULONG) (d));
  45.    }
  46. }
  47.  
  48. ULONG MakeDetailID (char a, char b, char c, char d) {
  49.  
  50. //   if (opts.SingleWindows) {
  51. //      return ((ULONG) ('M')<<24 | (ULONG) ('O')<<16 | (ULONG) ('R')<<8 | (ULONG) ('E'));
  52. //   } else {
  53.       return ((ULONG) (a)<<24 | (ULONG) (b)<<16 | (ULONG) (c)<<8 | (ULONG) (d));
  54. //   }
  55. }
  56.  
  57. struct Node *HandleNodeDetails (APTR list, char *type) {
  58.    struct ListEntry  *entryp;
  59.    struct Node       *node = NULL;
  60.  
  61.    if (entryp = GetActiveEntry (list)) {
  62.       node = MyFindName (type, entryp->le_address);
  63.       if (!node)
  64.          MyRequest ("Continue", "Sorry, can't find that %s!", type);
  65.    }
  66.    return (node);
  67. }
  68.  
  69. void MySetContents (APTR textfield, char *fmt, ...) {
  70.    va_list arg;
  71.    char buf[512];
  72.  
  73.    va_start(arg,fmt);
  74.    RawDoFmt(fmt, arg, (void (*)())"\x16\xc0\x4e\x75", buf);
  75.    va_end(arg);
  76.  
  77.    set (textfield, MUIA_Text_Contents, buf);
  78. }
  79.  
  80. void MySetContentsHealed (APTR textfield, char *fmt, ...) {
  81.    va_list arg;
  82.    char buf[512];
  83.  
  84.    va_start(arg,fmt);
  85.    RawDoFmt(fmt, arg, (void (*)())"\x16\xc0\x4e\x75", buf);
  86.    va_end(arg);
  87.  
  88.    healstring (buf);
  89.    set (textfield, MUIA_Text_Contents, buf);
  90. }
  91.  
  92. void MyFreePoolStructs (APTR *pool, APTR listtext1, APTR listtext2, APTR list)
  93. {
  94.     if (*pool) {
  95.         if (AP_Scout) {
  96.             if (listtext1) set (listtext1, MUIA_Text_Contents, "");
  97.             if (listtext2) set (listtext2, MUIA_Text_Contents, "");
  98.             if (list) DoMethod (list, MUIM_List_Clear);
  99.         }
  100.         tbDeletePool(*pool);
  101.         *pool = NULL;
  102.     }
  103. }
  104.  
  105. void SetCountText (APTR counttext, int structcnt) {
  106.    MySetContents (counttext, ESC "r%04ld", structcnt);
  107. }
  108.  
  109. void SetCloseRequest (APTR window, int id) {
  110.    DoMethod (window,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,AP_Scout,2,MUIM_Application_ReturnID,id);
  111. }
  112.  
  113. struct WinFree *SingleDetailWinFree = NULL;
  114.  
  115. char *MyGetWindowTitle (char *titleptr, char *type) {
  116.    int ok, i;
  117.  
  118.    if (type[0] == '\0') {
  119.       strcpy (tmpstr, "SCOUT");
  120.    } else {
  121.       _sprintf (tmpstr, "SCOUT: %s", type);
  122.    }
  123.    Forbid();
  124.    ok = (FindPort ("AMITCP") != NULL);
  125.    Permit();
  126.    if (ok) {
  127.       if (opts.Host) {
  128.          strcat (tmpstr, "   [ ");
  129.          strcat (tmpstr, opts.Host);
  130.          strcat (tmpstr, " ]");
  131.       } else {
  132.          strcat (tmpstr, "   [ LOCALHOST ]");
  133.       }
  134.    }
  135.  
  136.    for (i = 7; i < strlen (tmpstr); i++) {
  137.       tmpstr[i] = toupper (tmpstr[i]);
  138.    }
  139.    strcpy (titleptr, tmpstr);
  140.    return (titleptr);
  141. }
  142.  
  143. void HandleFlagsButtonPressed (APTR button, struct WinFree *ptr, char *title2, char *fieldname, ULONG flags, struct LongFlag *longflag, struct MaskedLongFlag *mlongflag, char fieldtype) {
  144.    struct WinFlag *winflag;
  145.  
  146.    if (!ptr->wf_Pool) ptr->wf_Pool = tbCreatePool(MEMF_CLEAR, 4096, 4096);
  147.  
  148.    if (winflag = tbAllocPooled(ptr->wf_Pool, sizeof(struct WinFlag))) {
  149.       winflag->wf_title2 = title2;
  150.       winflag->wf_fieldname = fieldname;
  151.       winflag->wf_flags = flags;
  152.       winflag->wf_longflag = longflag;
  153.       winflag->wf_mlongflag = mlongflag;
  154.       winflag->wf_fieldtype = fieldtype;
  155.       DoMethod (button,MUIM_Notify,MUIA_Pressed,FALSE,AP_Scout,3,MUIM_WriteLong,(ULONG) winflag,(ULONG *) &WinFlag_ToDo);
  156.    }
  157. }
  158.  
  159. void HandleWindowOpen (struct WinFree *ptr, char *titlepart1, char *titlepart2) {
  160.    UBYTE *fulltitle;
  161.    UBYTE *titlepart2ptr;
  162.  
  163.    if (opts.SingleWindows && SingleDetailWinFree) {
  164.       WinFree_ToDo = SingleDetailWinFree;
  165.       RemoveWinFree ();
  166.    }
  167.    SingleDetailWinFree = ptr;
  168.    titlepart2ptr = nonetest (titlepart2);
  169.  
  170.    if (!ptr->wf_Pool) ptr->wf_Pool = tbCreatePool(MEMF_CLEAR, 4096, 4096);
  171.    fulltitle = tbAllocPooled(ptr->wf_Pool, strlen(titlepart1) + strlen(titlepart2ptr) + 4);
  172.    _sprintf (fulltitle, "%s%s", titlepart1, titlepart2ptr);
  173.    healstring (fulltitle);
  174.  
  175.    set (ptr->wf_Window,MUIA_Window_Title,fulltitle);
  176.    DoMethod (AP_Scout,OM_ADDMEMBER,ptr->wf_Window);
  177.    SetWindowOpen (ptr->wf_Window,ptr->wf_ActiveObject,FALSE);
  178. }
  179.  
  180. void HandleWindowClose (struct WinFree *ptr) {
  181.    DoMethod (ptr->wf_Window,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,AP_Scout,3,MUIM_WriteLong,(ULONG) ptr,(ULONG *) &WinFree_ToDo);
  182.    SetCloseRequest (ptr->wf_Window,ID_REMOVEWINFREE);
  183. }
  184.  
  185. ULONG LastListID = 0;
  186.  
  187. void SetWindowOpen (APTR window, APTR active, ULONG ListID) {
  188.    if (opts.SingleWindows) {
  189.       if (ListID) {
  190.          if (LastListID && (LastListID != ListID)) {
  191.             if (SingleDetailWinFree) {
  192.                WinFree_ToDo = SingleDetailWinFree;
  193.                RemoveWinFree ();
  194.             }
  195.           DoMethod (AP_Scout,MUIM_Application_ReturnID,LastListID);
  196.          }
  197.          LastListID = ListID;
  198.       }
  199.    }
  200.  
  201.    set (window,MUIA_Window_Open,TRUE);
  202.    if (active) set(window, MUIA_Window_ActiveObject, active);
  203. }
  204.  
  205. void SetWindowClose (APTR window, BOOL IsList) {
  206.    if (opts.SingleWindows && IsList) {
  207.       if (SingleDetailWinFree) {
  208.          WinFree_ToDo = SingleDetailWinFree;
  209.          RemoveWinFree ();
  210.       }
  211.    }
  212.    set (window,MUIA_Window_Open,FALSE);
  213. }
  214.  
  215. void ApplicationSleep (void) {
  216.    set (AP_Scout,MUIA_Application_Sleep,TRUE);
  217. }
  218.  
  219. void AwakeApplication (void) {
  220.    set (AP_Scout,MUIA_Application_Sleep,FALSE);
  221. }
  222.  
  223. void RedrawActiveEntry (APTR list) {
  224.    DoMethod (list, MUIM_List_Redraw, MUIV_List_Redraw_Active);
  225. }
  226.  
  227. void RemoveActiveEntry (APTR list) {
  228.    DoMethod (list, MUIM_List_Remove, MUIV_List_Redraw_Active);
  229. }
  230.  
  231. void InsertBottomEntry (APTR list, APTR *entry) {
  232.    DoMethod (list, MUIM_List_Insert, entry, 1, MUIV_List_Insert_Bottom);
  233. }
  234.  
  235. void InsertSortedEntry (APTR list, APTR *entry) {
  236.    DoMethod (list, MUIM_List_Insert, entry, 1, MUIV_List_Insert_Sorted);
  237. }
  238.  
  239. struct ListEntry *GetActiveEntry (APTR list) {
  240.    struct ListEntry *result = NULL;
  241.    
  242.    if (list)
  243.       DoMethod (list,MUIM_List_GetEntry,MUIV_List_GetEntry_Active,&result);
  244.    return (result);
  245. }
  246.  
  247. void SetListActive (APTR list, int id) {
  248.    DoMethod (list,MUIM_Notify,MUIA_List_Active,MUIV_EveryTime,AP_Scout,2,MUIM_Application_ReturnID,id);
  249. }
  250.  
  251. void SetListviewDoubleClick (APTR list, int id) {
  252.    if (! clientstate)
  253.       DoMethod (list,MUIM_Notify,MUIA_Listview_DoubleClick,TRUE,AP_Scout,2,MUIM_Application_ReturnID,id);
  254. }
  255.  
  256. APTR KeyButtonA (char *buttontext, int buttonid) {
  257.    APTR result;
  258.    result = MUI_MakeObject (MUIO_Button, buttontext, MUIA_CycleChain, TRUE);
  259.    DoMethod (result,MUIM_Notify,MUIA_Pressed,FALSE,AP_Scout,2,MUIM_Application_ReturnID,buttonid);
  260.    return (result);
  261. }
  262.  
  263. APTR KeyButtonB (char *buttontext, char key, int buttonid) {
  264.    APTR result;
  265.    result = KeyButton (buttontext, key);
  266.    set(result, MUIA_CycleChain, TRUE);
  267.    DoMethod (result,MUIM_Notify,MUIA_Pressed,FALSE,AP_Scout,2,MUIM_Application_ReturnID,buttonid);
  268.    return (result);
  269. }
  270.  
  271. APTR KeyButtonF (char fieldtype, ULONG flags) {
  272.    APTR result;
  273.    char buttontext[16];
  274.  
  275.    if (fieldtype == 'l') {
  276.       _sprintf (buttontext, ESC "b$%08lx", (ULONG) flags);
  277.    } else if (fieldtype == 'w') {
  278.       _sprintf (buttontext, ESC "b$%04lx", (UWORD) flags);
  279.    } else {
  280.       _sprintf (buttontext, ESC "b%%%s", ltob ((ULONG) flags, 8));
  281.    }
  282.    result = TextObject,\
  283.                 ButtonFrame,\
  284.                       MUIA_Text_Contents, buttontext,\
  285.                 MUIA_Text_PreParse, "\33r",\
  286.                 MUIA_InputMode    , MUIV_InputMode_RelVerify,\
  287.                 MUIA_Background   , MUII_ButtonBack,\
  288.                 MUIA_CycleChain   , TRUE, \
  289.                 End;
  290.  
  291.    DoMethod (result,MUIM_Notify,MUIA_Pressed,FALSE,AP_Scout,2,MUIM_Application_ReturnID,ID_FLAGWINDOW);
  292.    return (result);
  293. }
  294.  
  295. __asm __saveds LONG flaglist_dspfunc(register __a2 char **array, register __a1 struct FlagEntry *flagentry, register __a0 struct Hook *hook)
  296. {
  297.    if (flagentry) {
  298.       *array++ = flagentry->fe_name;
  299.       *array++ = flagentry->fe_text;
  300.       *array   = NULL;
  301.    }
  302.    return(0);
  303. }
  304.  
  305. struct Hook flaglist_dsphook = {
  306.  {NULL, NULL},
  307.  (ULONG (* )())flaglist_dspfunc,
  308.  NULL, NULL
  309. };
  310.  
  311. void GetFlagsMore (char *title2, char *fieldname, ULONG flags, struct LongFlag *longflag, struct MaskedLongFlag *mlongflag, char fieldtype) {
  312.    unsigned char     flaglabel[40];
  313.    struct   WinFree  *ptr;
  314.    APTR  flagsmorelist;
  315.  
  316.  
  317.    if (fieldtype == 'l') {
  318.       _sprintf ((char *) &flaglabel, "%ls = $%08lx", fieldname, flags);
  319.    } else if (fieldtype == 'w') {
  320.       _sprintf ((char *) &flaglabel, "%ls = $%04lx", fieldname, flags);
  321.    } else {
  322.       _sprintf ((char *) &flaglabel, "%ls = %%%s", fieldname, ltob ((ULONG) flags, 8));
  323.    }
  324.  
  325.    if (ptr = AllocWinFree()) {
  326.       ptr->wf_Window = (APTR) WindowObject,
  327.  
  328. //      MUIA_Window_SizeGadget, FALSE,
  329.       MUIA_Window_ID, MakeDetailID('F','L','A','G'),
  330.       WindowContents, VGroup,
  331.          Child, HGroup,
  332.             Child, MyHSpace (0),
  333.             Child, MyLabel2 (flaglabel),
  334.             Child, MyHSpace (0),
  335.          End,
  336.          Child, flagsmorelist = ListviewObject,
  337.             MUIA_Listview_DoubleClick, TRUE,
  338.             MUIA_Listview_Input, FALSE,
  339.             MUIA_Listview_List, ListObject,
  340.             MUIA_List_Format, "COL=0 DELTA=8,COL=1",
  341. //            MUIA_List_Title, TRUE,
  342.             MUIA_List_DisplayHook, &flaglist_dsphook,
  343.             ReadListFrame,
  344.             End,
  345.          MUIA_CycleChain, TRUE,
  346.          End,
  347.       End, End;
  348.  
  349.       if (ptr->wf_Window) {
  350.          int i = 0;
  351.  
  352.          set(flagsmorelist,MUIA_List_Quiet,TRUE);
  353.          if (longflag) {
  354.             while (((struct LongFlag *) &longflag[i])->lf_name) {
  355.                if (flags & ((struct LongFlag *) &longflag[i])->lf_value) {
  356.                   DoMethod (flagsmorelist,MUIM_List_InsertSingle,((struct FlagEntry *) &((struct LongFlag *) &longflag[i])->lf_name),MUIV_List_Insert_Bottom);
  357.                }
  358.                i++;
  359.             }
  360.          }
  361.          i = 0;
  362.          if (mlongflag) {
  363.             while (((struct MaskedLongFlag *) &mlongflag[i])->mlf_name) {
  364.                if ((flags & ((struct MaskedLongFlag *) &mlongflag[i])->mlf_mask) == ((struct MaskedLongFlag *) &mlongflag[i])->mlf_value) {
  365.                   DoMethod (flagsmorelist,MUIM_List_InsertSingle,((struct FlagEntry *) &((struct MaskedLongFlag *) &mlongflag[i])->mlf_name),MUIV_List_Insert_Bottom);
  366.                }
  367.                i++;
  368.             }
  369.          }
  370.          set(flagsmorelist,MUIA_List_Quiet,FALSE);
  371.  
  372.          HandleWindowOpen (ptr, "FLAGS  ", title2);
  373.          set (ptr->wf_Window,MUIA_Window_ActiveObject,flagsmorelist);
  374.          HandleWindowClose (ptr);
  375.       }
  376.    }
  377. }
  378.  
  379. APTR MyListviewObject (unsigned char *formatstring, APTR displayhook ) {
  380.    return (ListviewObject,
  381.             MUIA_Listview_List, ListObject,
  382.             MUIA_List_Format, formatstring,
  383.             MUIA_List_Title, TRUE,
  384.             MUIA_List_DisplayHook, displayhook,
  385.             InputListFrame,
  386.            End,
  387.            MUIA_CycleChain, TRUE,
  388.            End);
  389. }
  390.  
  391. APTR MySortedListviewObject (unsigned char *formatstring, APTR displayhook, APTR comparehook) {
  392.    return (ListviewObject,
  393.             MUIA_Listview_List, ListObject,
  394.             MUIA_List_Format, formatstring,
  395.             MUIA_List_Title, TRUE,
  396.             MUIA_List_DisplayHook, displayhook,
  397.             MUIA_List_CompareHook, comparehook,
  398.             InputListFrame,
  399.            End,
  400.            MUIA_CycleChain, TRUE,
  401.            End);
  402. }
  403.  
  404. /*
  405. APTR MyBelowSortedListview (APTR *text, APTR *count, APTR *cycle, const char *sorttext[], int sortstate) {
  406.  return (HGroup,
  407.             Child, VGroup,
  408.                Child, *text = MyTextObject5(SPACE40),
  409.                   Child, MyLabel ("sorted by:"),
  410.                End,
  411.                Child, VGroup, MUIA_HorizWeight, 0,
  412.                   Child, HGroup,
  413.                      Child, MyLabel (" Cnt:"),
  414.                      Child, *count = MyTextObject4("0000"),
  415.                   End,
  416.                   Child, *cycle = CycleObject,
  417.                      MUIA_Cycle_Entries, sorttext,
  418.                      MUIA_Cycle_Active, sortstate,
  419.                   End,
  420.                End,
  421.             End);
  422. }
  423. */
  424.  
  425. APTR MyBelowSortedListview (APTR *text, APTR *count, APTR *cycle, const char *sorttext[], int sortstate) {
  426.  return (HGroup,
  427.             Child, *text = MyTextObject5(SPACE40),
  428.             Child, HGroup, MUIA_HorizWeight, 0,
  429.                Child, MyLabel (" Cnt:"),
  430.                Child, *count = MyTextObject4("0000"),
  431.                Child, MyLabel ("sorted by:"),
  432.                Child, *cycle = CycleObject,
  433.                   MUIA_Cycle_Entries, sorttext,
  434.                   MUIA_Cycle_Active, sortstate,
  435.                End,
  436.             End,
  437.          End);
  438. }
  439.  
  440. APTR MyBelowListview (APTR *text, APTR *count) {
  441.  return (HGroup,
  442.          Child, *text = MyTextObject5(SPACE40),
  443.          Child, HGroup, MUIA_HorizWeight, 0,
  444.             Child, MyLabel (" Cnt:"),
  445.             Child, *count = MyTextObject4("0000"),
  446.          End,End);
  447. }
  448.  
  449. APTR MyLabel (char *labeltext) {
  450.    return (LabelA (labeltext));
  451. }
  452.  
  453. APTR MyLabel2 (char *labeltext) {
  454.    return (LabelB (labeltext));
  455. }
  456.  
  457. APTR MyHSpace (int size) {
  458.    return (HSpace (size));
  459. }
  460.  
  461. APTR MyVSpace (int size) {
  462.    return (VSpace (size));
  463. }
  464.  
  465. APTR MyTextObject () {
  466.    return ( TextObject, MyTextFrame, End );
  467. }
  468.  
  469. APTR MyTextObject2 () {
  470.    return ( TextObject, MyTextFrame, MUIA_Text_SetMax, TRUE, End );
  471. }
  472.  
  473. APTR MyTextObject3 (char *text) {
  474.    return ( TextObject, MyTextFrame, MUIA_Text_Contents, text, End );
  475. }
  476.  
  477. APTR MyTextObject4 (char *text) {
  478.    return ( TextObject, MyTextFrame, MUIA_Text_SetMax, TRUE, MUIA_Text_Contents, text, End );
  479. }
  480.  
  481. APTR MyTextObject5 (char *text) {
  482.    return ( TextObject, MyTextFrame, MUIA_Text_SetMin, TRUE, MUIA_Text_Contents, text, End );
  483. }
  484.  
  485. APTR MyTextObject6 (char *text, struct TextFont *font) {
  486.    return ( TextObject, MyTextFrame, MUIA_Text_SetMin, TRUE, MUIA_Text_Contents, text, MUIA_Font, font, End );
  487. }
  488.  
  489. __asm __saveds LONG list_cmpaddressfunc (register __a1 struct ListEntry *le1, register __a2 struct ListEntry *le2) {
  490.    return (strcmpi (le1->le_address, le2->le_address));
  491. }
  492.  
  493. struct Hook list_cmpaddresshook = {
  494.  {NULL, NULL},
  495.  (ULONG (* )())list_cmpaddressfunc,
  496.  NULL, NULL
  497. };
  498.  
  499. __asm __saveds LONG list_cmpnormalfunc (register __a1 struct ListEntry *le1, register __a2 struct ListEntry *le2)
  500. {
  501.    return (1);
  502. }
  503.  
  504. struct Hook list_cmpnormalhook = {
  505.  {NULL, NULL},
  506.  (ULONG (* )())list_cmpnormalfunc,
  507.  NULL, NULL
  508. };
  509.  
  510. __asm __saveds LONG list_cmpnamefunc (register __a1 struct ListEntry *le1, register __a2 struct ListEntry *le2)
  511. {
  512.    return strcmpi (le1->le_name, le2->le_name);
  513. }
  514.  
  515. struct Hook list_cmpnamehook = {
  516.  {NULL, NULL},
  517.  (ULONG (* )())list_cmpnamefunc,
  518.  NULL, NULL
  519. };
  520.  
  521. char main_title[WINDOWTITLELEN];
  522.  
  523. APTR GetApplication (void) {
  524.    AP_Scout = ApplicationObject,
  525.       MUIA_Application_Title      , PROGNAME,
  526.       MUIA_Application_Version    , version_date,
  527.       MUIA_Application_Copyright  , COPYRIGHT,
  528.       MUIA_Application_Author     , AUTHOR,
  529.       MUIA_Application_Description, DESCRIPTION,
  530.       MUIA_Application_Base       , PROGNAME,
  531.       MUIA_Application_Commands   , arexx_list,
  532.       MUIA_Application_Menu       , menu_list,
  533. //      MUIA_Application_SingleTask , TRUE,
  534.       MUIA_Application_DiskObject , GetDiskObject("PROGDIR:Scout"),
  535.       MUIA_Application_HelpFile   , "scout.guide",
  536.    End;
  537.  
  538.    if (AP_Scout) {
  539.       WI_Main = WindowObject,
  540.       MUIA_Window_Title, MyGetWindowTitle (main_title, ""),
  541.          MUIA_HelpNode, "Main",
  542.          MUIA_Window_ID, MakeID('M','A','I','N'),
  543.          WindowContents, HGroup,
  544.             MUIA_Group_SameHeight, TRUE,
  545.             Child, VGroup,                  /* This is the SCOUT logo */
  546.                MUIA_Weight    , 0,
  547.                MUIA_Frame     , MUIV_Frame_Text,
  548.                MUIA_Background, MUII_SHADOW,
  549.                Child, VSpace(0),
  550.                Child, BodychunkObject,
  551.                   MUIA_FixWidth             , SCOUT_LOGO_WIDTH ,
  552.                   MUIA_FixHeight            , SCOUT_LOGO_HEIGHT,
  553.                   MUIA_Bitmap_Width         , SCOUT_LOGO_WIDTH ,
  554.                   MUIA_Bitmap_Height        , SCOUT_LOGO_HEIGHT,
  555.                   MUIA_Bodychunk_Depth      , SCOUT_LOGO_DEPTH ,
  556.                   MUIA_Bodychunk_Body       , scout_logo_body  ,
  557.                   MUIA_Bodychunk_Compression, SCOUT_LOGO_COMPRESSION,
  558.                   MUIA_Bodychunk_Masking    , SCOUT_LOGO_MASKING,
  559.                   MUIA_Bitmap_SourceColors  , scout_logo_colors,
  560.                   MUIA_Bitmap_Transparent   , 0,
  561.                End,
  562.                Child, VSpace(0),
  563.             End,
  564.             Child, ColGroup(5), MUIA_Group_SameSize, TRUE,             /* And this are the buttons */
  565.                Child, BT_Allocations  = KeyButtonB (AllocationsText  ,'a',ID_ALLOCATIONS),  // 5
  566.                Child, BT_Assigns      = KeyButtonB (AssignsText      ,'g',ID_ASSIGNS),      // 16
  567.                Child, BT_Classes      = KeyButtonB (ClassesText      ,'b',ID_CLASSES),      // 14
  568.                Child, BT_Commodities  = KeyButtonB (CommoditiesText  ,'k',ID_COMMODITIES),  // 8
  569.                Child, BT_Devices      = KeyButtonB (DevicesText      ,'d',ID_DEVICES),      // 2
  570.  
  571.                Child, BT_Expansions   = KeyButtonB (ExpansionsText   ,'x',ID_EXPANSIONS),   // 22
  572.                Child, BT_Fonts        = KeyButtonB (FontsText        ,'f',ID_FONTS),        // 13
  573.                Child, BT_InputHandler = KeyButtonB (InputHandlersText,'h',ID_INPUTHANDLER), // 15
  574.                Child, BT_Interrupts   = KeyButtonB (InterruptsText   ,'i',ID_INTERRUPTS),   // 9
  575.                Child, BT_Libraries    = KeyButtonB (LibrariesText    ,'l',ID_LIBRARIES),    // 1
  576.  
  577.                Child, BT_Locks        = KeyButtonB (LocksText        ,'o',ID_LOCKS),        // 17
  578.                Child, BT_LowMemory    = KeyButtonB (LowMemoryText    ,'j',ID_LOWMEMORY),    // 24
  579.                Child, BT_Memory       = KeyButtonB (MemoryText       ,'m',ID_MEMORY),       // 23
  580.                Child, BT_Mount        = KeyButtonB (MountText        ,'n',ID_MOUNT),        // 18
  581.                Child, BT_Ports        = KeyButtonB (PortsText        ,'p',ID_PORTS),        // 7
  582.  
  583.                Child, BT_Residents    = KeyButtonB (ResidentsText    ,'r',ID_RESIDENTS),    // 25
  584.                Child, BT_Commands     = KeyButtonB (CommandsText     ,'c',ID_COMMANDS),     // 19
  585.                Child, BT_Resources    = KeyButtonB (ResourcesText    ,'u',ID_RESOURCES),    // 3
  586.                Child, BT_ScreenMode   = KeyButtonB (ScreenModeText   ,'z',ID_SCREENMODE),   // 11
  587.                Child, BT_Semaphores   = KeyButtonB (SemaphoresText   ,'s',ID_SEMAPHORES),   // 4
  588.  
  589.                Child, BT_System       = KeyButtonB (SystemText       ,'y',ID_SYSTEM),       // 21
  590.                Child, BT_Tasks        = KeyButtonB (TasksText        ,'t',ID_TASKS),        // 6
  591.                Child, BT_Timer        = KeyButtonB (TimerText        ,'e',ID_TIMER),        // 20
  592.                Child, BT_Vectors      = KeyButtonB (VectorsText      ,'v',ID_VECTORS),      // 10
  593.                Child, BT_Windows      = KeyButtonB (WindowsText      ,'w',ID_WINDOWS),      // 12
  594.             End,
  595.          End,
  596.       End;
  597.  
  598.       if (WI_Main) {
  599.          DoMethod (AP_Scout,OM_ADDMEMBER,WI_Main);
  600.          SetCloseRequest (WI_Main,(int) MUIV_Application_ReturnID_Quit);
  601.          DoMethod (WI_Main,MUIM_Window_SetCycleChain,
  602.                     BT_Libraries,BT_Devices,BT_Resources,BT_System,
  603.                     BT_Tasks,BT_Ports,BT_Commands,BT_Commodities,
  604.                     BT_Expansions,BT_Memory,BT_Residents,BT_LowMemory,
  605.                     BT_Assigns,BT_Locks,BT_Mount,BT_Timer,
  606.                     BT_InputHandler,BT_Interrupts,BT_Vectors,BT_Allocations,
  607.                     BT_Fonts,BT_Semaphores,BT_Windows,BT_ScreenMode,NULL);
  608.  
  609. //         DoMethod (AP_Scout,MUIM_Notify,MUIA_Application_DoubleStart,TRUE,AP_Scout,2,MUIM_Application_ReturnID,ID_DOUBLESTART);
  610.       }
  611.    }
  612.    return (AP_Scout);
  613. }
  614.  
  615. __asm __saveds void cpuinterval_callfunc(register __a1 unsigned char **contents) {
  616.    int      i, j, t;
  617.    long     micros = 0;
  618.    UBYTE    text[8];
  619.  
  620.    if ((switchstate) && (*switchstate)) {
  621.       AbortIO ((struct IORequest *) TimerIORequest);
  622.    }
  623.  
  624.    strncpy (text, *contents, 6);
  625.  
  626.    i = 0;
  627.    while ((text[i] != '\0') && (text[i] != '.')) {
  628.       i++;
  629.    }
  630.    if (text[i] == '.') {
  631.       t = 1;
  632.       text[i] = '\0';
  633.       while (isdigit (text[++i])) {
  634.          if (j = (int) (text[i] - '0')) {
  635.             t *= 10;
  636.             micros += (1000000 / t) * j;
  637.          }
  638.       }
  639.    }
  640.    cpumicros = micros;
  641.    cpuseconds = atol ((char const *) &text);
  642.    strcpy (updatetimetext,*contents);
  643.  
  644.    if ((switchstate) && (*switchstate)) {
  645.       TimerIORequest->tr_time.tv_secs = cpuseconds;
  646.       TimerIORequest->tr_time.tv_micro = cpumicros;
  647.       TimerIORequest->tr_node.io_Command = TR_ADDREQUEST;
  648.       SendIO ((struct IORequest *) TimerIORequest);
  649.    }
  650. }
  651.  
  652. struct Hook cpuinterval_callhook = {
  653.  {NULL, NULL},
  654.  (ULONG (* )())cpuinterval_callfunc,
  655.  NULL, NULL
  656. };
  657.  
  658. /* Beispiel-EditHook aus RKM-Libraries Seite 164 */
  659. /*
  660. __asm __saveds ULONG realstring_editfunc(register __a0 struct Hook *hook, register __a2 struct SGWork *sgw, register __a1 ULONG *msg) {
  661.    UBYTE *work_ptr;
  662.    ULONG return_code;
  663.  
  664.    return_code = ~0L;
  665.  
  666.    if (*msg == SGH_KEY) {
  667.       if ((sgw->EditOp == EO_REPLACECHAR) || (sgw->EditOp == EO_INSERTCHAR)) {
  668.          if (!IsHexDigit (sgw->Code)) {
  669.             sgw->Actions |= SGA_BEEP;
  670.             sgw->Actions &= ~SGA_USE;
  671.          } else {
  672.             sgw->WorkBuffer[sgw->BufferPos - 1] = ToUpper (sgw->Code);
  673.          }
  674.       }
  675.    } else if (*msg == SGH_CLICK) {
  676.       if (sgw->BufferPos < sgw->NumChars) {
  677.          work_ptr = sgw->WorkBuffer + sgw->BufferPos;
  678.          *work_ptr = '0';
  679.       }
  680.    } else {
  681.       return_code = 0;
  682.    }
  683.    return (return_code);
  684. }
  685. */
  686.  
  687. __asm __saveds ULONG hexstring_editfunc (register __a0 struct Hook *hook, register __a2 struct SGWork *sgw, register __a1 ULONG *msg) {
  688.    ULONG return_code;
  689.    int   i = 0;
  690.    char  c;
  691.  
  692.    return_code = ~0L;
  693.  
  694.    if (*msg == SGH_KEY) {
  695.       long  tmplong;
  696.  
  697.       if ((sgw->EditOp == EO_REPLACECHAR) || (sgw->EditOp == EO_INSERTCHAR)) {
  698.          if (sgw->WorkBuffer[0] == '$')
  699.             i = 1;
  700.          if (! strncmp ("0x", sgw->WorkBuffer, 2))
  701.             i = 2;
  702.          while (c = sgw->WorkBuffer[i]) {
  703.             if ((! ((c >= '0') && (c <= '9'))) \
  704.               && (! ((c >= 'a') && (c <= 'f'))) \
  705.               && (! ((c >= 'A') && (c <= 'F')))) {
  706.                sgw->Actions |= SGA_BEEP;
  707.                sgw->Actions &= ~SGA_USE;
  708.                break;
  709.             }
  710.             i++;
  711.          }
  712.       } else if ((sgw->EditOp == EO_ENTER) && (! IsHex (sgw->WorkBuffer, &tmplong))) { 
  713.          sgw->Actions |= SGA_BEEP;
  714.          sgw->Actions &= ~SGA_END;
  715.       }
  716.    } else {
  717.       return_code = 0;
  718.    }
  719.    return (return_code);
  720. }
  721.  
  722. struct Hook hexstring_edithook = {
  723.  {NULL, NULL},
  724.  (ULONG (* )())hexstring_editfunc,
  725.  NULL, NULL
  726. };
  727.  
  728. __asm __saveds ULONG realstring_editfunc(register __a0 struct Hook *hook, register __a2 struct SGWork *sgw, register __a1 ULONG *msg) {
  729.    ULONG return_code;
  730.    int   i = 0,punkte = 0,notzeros = 0;
  731.  
  732.    return_code = ~0L;
  733.  
  734.    if (*msg == SGH_KEY) {
  735.       if ((sgw->EditOp == EO_REPLACECHAR) || (sgw->EditOp == EO_INSERTCHAR)) {
  736.          while (sgw->WorkBuffer[i]) {
  737.             if (sgw->WorkBuffer[i++] == '.')
  738.                punkte++;
  739.          }
  740.          if ((punkte > 1) || ((!isdigit (sgw->Code)) && (sgw->Code != '.'))) {
  741.             sgw->Actions |= SGA_BEEP;
  742.             sgw->Actions &= ~SGA_USE;
  743.          }
  744.       } else if (sgw->EditOp == EO_ENTER) {
  745.          while (sgw->WorkBuffer[i]) {
  746.             if ((sgw->WorkBuffer[i] >= '1') && (sgw->WorkBuffer[i] <= '9'))
  747.                notzeros++;
  748.             i++;
  749.          }
  750.          if ((sgw->EditOp == EO_ENTER) && (!notzeros)) { 
  751.             sgw->Actions |= SGA_BEEP;
  752.             sgw->Actions &= ~SGA_END;
  753.          }
  754.       }
  755.    } else {
  756.       return_code = 0;
  757.    }
  758.    return (return_code);
  759. }
  760.  
  761. struct Hook realstring_edithook = {
  762.  {NULL, NULL},
  763.  (ULONG (* )())realstring_editfunc,
  764.  NULL, NULL
  765. };
  766.  
  767. void AboutWindow (BOOL state) {
  768.    if ((state) && (! WI_About)) {
  769.       WI_About = WindowObject,
  770.       MUIA_Window_Title, vers,
  771.       WindowContents, VGroup,
  772.          Child, AboutText= MyTextObject2(),
  773.          Child, MyVSpace(4),
  774.          Child, HGroup, MUIA_Group_SameSize, TRUE,
  775.             Child, MyHSpace(0),
  776.             Child, BT_AboutContinue = KeyButtonA (ContinueText,ID_ABOUTCONTINUE),
  777.             Child, MyHSpace(0),
  778.          End,
  779.       End, End;
  780.  
  781.       if (WI_About) {
  782.          MySetContents (AboutText, MUIX_C "\n" \
  783.                                    "%s\n" \
  784.                                    "%s\n" \
  785.                                    "\n" \
  786.                                    COPYRIGHT "\n" \
  787.                                    "All Rights Reserved\n" \
  788.                                    "\n" \
  789.                                    "This program is \33bFreeware\33n.\n" \
  790.                                    "EMail: " EMAIL "\n" \
  791.                                    /* "URL: " URL "\n" \ */
  792.                                    "\n" \
  793.                                    "ARexx port name: %s\n", vstring, release, portname);
  794.  
  795.          DoMethod (AP_Scout,OM_ADDMEMBER,WI_About);
  796.          SetCloseRequest (WI_About,ID_ABOUTCONTINUE);
  797.  
  798.          SetWindowOpen (WI_About,BT_AboutContinue,FALSE);
  799.       }
  800.    } else if ((! state) && (WI_About)) {
  801.       SetWindowClose (WI_About,FALSE);
  802.  
  803.       DoMethod (AP_Scout,OM_REMMEMBER,WI_About);
  804.       MUI_DisposeObject (WI_About);
  805.       WI_About = NULL;
  806.    }
  807. }
  808.  
  809.